<!--客户详情-->
<template>
  <div class="contain">
    <app-header></app-header>
    <div class="list-cwarp mb30">
      <div class="displayflex">
        <div class="cpy-icon"><i class="iconfont icon-factory"></i></div>
        <div class="list-cline flex1 hauto">
          <h2 class="tit">{{datas.Name}}{{datas.OrgType | type}}</h2>
          <p class="tip">{{datas.Province | province}} {{datas.City | city}} {{datas.District | district }}{{datas.Address}}</p>
          <!-- <div class="tag" v-if="datas.OrgRank">{{datas.OrgRank | rank}}{{datas.OrgGrade | grade}}</div> -->
        </div>
      </div>
    </div>

    <!-- <uploader :title="'公司照片'" :img-list="imgList" :max="0"></uploader> -->

    <h2 class="form-tit-row">联系人</h2>
    <div class="form-wrap">
      <div class="form-wrap-row">
        <div class="top">姓名</div>
        <div class="bottom">{{datas.LinkMan}}</div>
      </div>
      <div class="form-wrap-row">
        <div class="top">手机号</div>
        <div class="bottom">{{datas.ContactTel}}</div>
      </div>
    </div>
    <!-- <div v-if="this.$route.query.StaffID">
      <h2 class="form-tit-row" v-if="StaffID">已有账号</h2>
      <div class="form-switch mb30">
        <x-switch prevent-default :title="label" v-model="switchV" @on-click="checked"></x-switch>
      </div>
    </div> -->
    <!--<div class="displayflex form-btn">
      <div class="flex1" @click="editUser(datas.StaffID, 'view')" v-if="thisStaffID">账号信息</div>
      <div class="flex1" @click="createUser(datas.Guid)" v-if="!thisStaffID">开通账号</div>
       <div class="flex1" @click="customEdit(datas.Guid)">编辑资料</div> 
    </div>-->
  </div>
</template>

<script>
import appHeader from '@/components/core/header/app_header.vue';
import uploader from '@/components/share/imageUploader/imageUploader.vue';

export default {
  components:{
    appHeader,
    uploader
  },
  data() {
    return {
      thisStaffID: this.$route.query.StaffID,
      datas:[],
      imgList:[],
      switchV:true,
      label:'',
      list:[]
    }
  },
  computed:{
    StaffID(){
      return this.$route.query.StaffID;
    }
  },
  created(){
    
  },
  mounted() {
    this.$nextTick(function() {
      this.getData()
    })
  },
  methods: {
    //modi by lxf
    checked (){
      var self = this,
          orgValue = this.switchV?'Y':'N',
          op = this.switchV?'禁用':'启用';
      this.MessageBox.confirm('是否'+op+'账户').then(action => {
        var query = {
              StaffID: this.datas.StaffID,
              IsDeleted: orgValue,
            };
        this.Ajax.post('SwitchUserState', query).then(function(resp) {
          if (resp.IsSuccess) {
            self.switchV = !self.switchV;
          }
        });
      })
    },
    createUser(itemGuid){
      this.$router.push({ path: 'customReguser', query: { Guid: itemGuid } })
    },
    editUser(itemGuid, edit){
      this.$router.push({ path: 'customReguser', query: { Guid: itemGuid, mode: edit} })
    },
    //end modi
    customEdit(id){
      this.$router.push({
        path:'/customForm', query: { Guid: id } 
      })
    },

    getData(){
      let self = this,
          guid = this.$route.query.Guid,
          userinfo = JSON.parse(localStorage.userinfo),
          query = {
            Guid: guid,
          };
      if(this.$route.query.StaffID) query.StaffID = this.$route.query.StaffID;
      //GetmfmedByInfo
      this.Ajax.post('GetMfmedInfo', query).then((resp) => {
        if(resp.IsSuccess){
          self.datas = resp.Data;
          self.label = self.datas.StaffName + ' ' + self.datas.StaffLogonUser;

          var staffS = self.datas.StaffIsDeleted;
          if(staffS == 'N'){
            self.switchV = true;
          } else if(staffS == 'Y') {
            self.switchV = false;
          }

          let imgStr = this.datas.PictContent;
          if (imgStr && imgStr != "null" && imgStr != '') {
            this.imgList = JSON.parse(imgStr);
          }
        } else {
          this.Toast({
            message: resp.ErrorMessage || '操作异常，请稍后重试',
          });
        }
      });
    }
  },
  filters:{
    type(val){
      if(!val) return '';
      switch (val){
        case "1":
          return "（医院）";
          break;
        case "2":
          return "（公司）";
          break;
      };
    }
  }
}
</script>